var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this
    that.getCatefenleione()
    if (options.id) {
      app.util.request({
        'url': 'entry/wxapp/tijian.detailist',
        data: {
          id: options.id
        },
        'cachetime': '30',
        success: function(res) {
          wx.hideLoading()
          that.setData({
            list: res.data,
            id: options.id
          })
        }
      })
    } else {
      that.getAlllist()
    }
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  getCatefenleione() {
    var that = this
    app.util.request({
      'url': 'entry/wxapp/tijian.catefenleione',
      success: function(res) {
        console.log(res)
        that.setData({
          cate: res.data
        })
      }
    })
  },
  getAlllist() {
    var that = this
    app.util.request({
      'url': 'entry/wxapp/tijian.detailist',
      data: {
        id: 0
      },
      'cachetime': '30',
      success: function(res) {
        console.log(res)
        wx.hideLoading()
        that.setData({
          list: res.data
        })
      }
    })
  },
  checkItemTap: function(e) {
    var that = this
    var id = e.currentTarget.dataset.id
    var xuan = e.currentTarget.dataset.index
    wx.showLoading({
      title: '加载中',
    })
    app.util.request({
      'url': 'entry/wxapp/tijian.detailist',
      data: {
        id: id
      },
      'cachetime': '30',
      success: function(res) {
        wx.hideLoading()
        that.setData({
          list: res.data,
          xuan: xuan,
          id: ''
        })
      }
    })
  },
  goDetail(e) {
    var that = this
    var tid = e.currentTarget.dataset.tid
    wx.navigateTo({
      url: '/hyb_yl/userLife/pages/tijian/detail/detail?tid=' + tid
    })
  }
})